<template>
  <view>
    <evaluate-show  :evaluates="evaluates" @del="del" :actionShow="actionShow"></evaluate-show>
    <uni-load-more v-if="queryParams.pageSize<evaluates.length" color="#007AFF" :status="status" />
  </view>
</template>

<script>
import {RepairEvaluateService} from "../repairEvaluateService";
import EvaluateShow from "../../../../components/EvaluateShow";

export default {
  components: {EvaluateShow},
  data() {
    return {
      evaluates:[],
      actionShow:true,
      queryParams: {
        currentPage: 1,
        pageSize: 5,
        filters: {

        },
        orderBys: [
          {
            property: "createDatetime",
            order: "desc"
          }
        ]
      },
      totalCount:100,
      status:"more"
    }
  },
  onReachBottom() {
    console.log("上拉刷新")
    // uni.$emit('onReachBottom',"刷新数据");
    //触底业务逻辑
    if(this.queryParams.pageSize*this.queryParams.currentPage>=this.totalCount){
      this.status="nomore"
      return;
    }
    this.queryParams.currentPage++;
    this.init(1);
  },
  created(){
    let user=uni.getStorageSync('userInfo').userInfo;
    // console.log(user)
    if(user.userType=='user'){
      this.queryParams.filters.userId=user.eid
    }else{
      this.queryParams.filters.repairUserId=user.eid
      this.actionShow=false
    }
    this.init(0);
  },
  methods: {
    init(type){
      this.status="loading"
      if(type==0){this.evaluates=[];this.queryParams.currentPage=1}
      RepairEvaluateService.findRepairEvaluates(this.queryParams).then(res=>{
        //拼接数组
        this.evaluates=this.evaluates.concat( res.data.datas);
        this.totalCount=res.data.totalCount;
        this.status='more'
      })
    },
    del(index){
      console.log(this.evaluates,index)
      this.evaluates.splice(index,1)
      console.log(this.evaluates)
    }
  }
}
</script>


